<template>
  <div class="dashboard-container">
    <el-row>
      <el-col :span="24">
        <el-tabs type="border-card" tab-position="left" style="height:1000px;">
          <!-- 任务页面tab -->
          <el-tab-pane>
            <span slot="label">
              任务
              <el-badge v-if="taskList.unRead != 0" :value="taskList.unRead" class="badge" />
            </span>
            <el-table v-loading="taskList.listLoading" :data="taskList.list" style="width: 100%"
              element-loading-text="Loading" border stripe fit highlight-current-row>
              <el-table-column label="审批状态" align="center" width="100px">
                <template slot-scope="scope">
                  <b>
                    <el-tag v-if="scope.row.sta == 3" type="info">{{ getTaskStaStr(scope.row.sta) }}</el-tag>
                    <el-tag v-if="scope.row.sta == 1" type="success">{{ getTaskStaStr(scope.row.sta) }}</el-tag>
                    <el-tag v-if="scope.row.sta == 0" type="warning">{{ getTaskStaStr(scope.row.sta) }}</el-tag>
                    <el-tag v-if="scope.row.sta == 2" type="danger">{{ getTaskStaStr(scope.row.sta) }}</el-tag>
                  </b>
                </template>
              </el-table-column>
              <el-table-column label="业务类型" align="center" width="100px">
                <template slot-scope="scope">
                  <b>
                    <el-tag>{{ getTypeStr(scope.row.typ) }}</el-tag>
                  </b>
                </template>
              </el-table-column>
              <el-table-column label="申请时间" align="center" width="110px">
                <template slot-scope="scope">{{ formatYearMonthDay(scope.row.createTime) }}</template>
              </el-table-column>

              <el-table-column label="标题" align="center">
                <template slot-scope="scope">{{ scope.row.title }}</template>
              </el-table-column>
              <el-table-column label="内容">
                <template slot-scope="scope">
                  <!-- {{ scope.row.content }} -->
                  <div style="white-space: pre-wrap;">{{ formatContent(scope.row.content) }}</div>
                </template>
              </el-table-column>

              <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                  <el-button v-if="(scope.row.sta == 0)" size="mini" type="primary" plain
                    @click="showShenpiDialog(scope.$index, scope.row)">审批</el-button>
                  <el-button size="mini" type="primary" plain
                    @click="seeDetail(scope.row.typ, scope.row.relevenceId, scope.row.id)">查看详情</el-button>
                  <el-button v-if="scope.row.sta == 0 && scope.row.typ == 18 && userInfo.uid == 4" size="mini"
                    type="primary" plain @click="revertGongwen(scope.row.relevenceId)">撤回</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div style="padding-top: 20px;" />
            <el-pagination :current-page="taskList.pageIndex" :page-sizes="[10, 20, 50, 100]"
              :page-size="taskList.pageCount" layout="total, prev, pager, next, jumper" :total="taskList.dataTotal"
              @size-change="onTaskPageSizeChange" @current-change="onTaskCurrentPageChange" />
          </el-tab-pane>

          <!-- 通知页面Tab -->
          <el-tab-pane>
            <span slot="label">
              通知
              <el-badge v-if="noticeList.unRead != 0" :value="noticeList.unRead" class="badge" />
            </span>
            <el-table v-loading="noticeList.listLoading" :data="noticeList.list" style="width: 100%"
              element-loading-text="Loading" border stripe fit highlight-current-row>
              <el-table-column label="状态" align="center" width="100px">
                <template slot-scope="scope">
                  <b>
                    <el-tag v-if="scope.row.sta == 0" type="danger">未读</el-tag>
                    <el-tag v-if="scope.row.sta != 0" type="info">已读</el-tag>
                  </b>
                </template>
              </el-table-column>
              <el-table-column label="发布时间" align="center" width="100px">
                <template slot-scope="scope">{{ formatYearMonthDay(scope.row.createTime) }}</template>
              </el-table-column>
              <!-- <el-table-column label="发布人" align="center">
            <template slot-scope="scope">
              1
            </template>
              </el-table-column>-->
              <el-table-column label="通知类型" align="center" width="100px">
                <template slot-scope="scope">
                  <b>
                    <el-tag>{{ getTypeStr(scope.row.typ) }}</el-tag>
                  </b>
                </template>
              </el-table-column>
              <el-table-column label="标题" align="center">
                <template slot-scope="scope">{{ scope.row.title }}</template>
              </el-table-column>
              <el-table-column label="内容" align="center">
                <template slot-scope="scope">{{ scope.row.content }}</template>
              </el-table-column>
              <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                  <el-button size="mini" type="primary" plain
                    @click="seeDetailNotice(scope.$index, scope.row.typ, scope.row.relevenceId)">查看详情</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div style="padding-top: 20px;" />

            <el-pagination :current-page="noticeList.pageIndex" :page-sizes="[10, 20, 50, 100]"
              :page-size="noticeList.pageCount" layout="total, prev, pager, next, jumper" :total="noticeList.dataTotal"
              @size-change="onNoticePageSizeChange" @current-change="onNoticeCurrentPageChange" />
          </el-tab-pane>

          <el-tab-pane label="历史公文">
            <el-input style="width: 80%;" placeholder="请输入搜索内容" v-model="gongwenHistoryList.keyword"></el-input>
            <el-button style="width:10%" type="primary" @click="getGongwenHistoryList">搜索</el-button>
            <el-table v-loading="gongwenHistoryList.listLoading" :data="gongwenHistoryList.list" style="width: 100%"
              element-loading-text="Loading" border stripe fit highlight-current-row>
              <el-table-column label="业务类型" align="center" width="100px">
                <template slot-scope="scope">
                  <b>
                    <el-tag> {{ getTypeStr(scope.row.typ) }}</el-tag>
                  </b>
                </template>
              </el-table-column>
              <el-table-column label="标题" align="center">
                <template slot-scope="scope">
                  {{ scope.row.title }}
                </template>
              </el-table-column>
              <el-table-column label="内容摘要" align="center">
                <template slot-scope="scope">
                  {{ scope.row.content }}
                </template>
              </el-table-column>
              <el-table-column label="收藏时间" align="center">
                <template slot-scope="scope">
                  {{ formatYearMonthDay(scope.row.createTime) }}
                </template>
              </el-table-column>
              <!-- <el-table-column label="图片" align="center">
            <template slot-scope="scope">

              <el-button size="mini" type="info" plain><i class="el-icon-picture-outline" /> 图片</el-button>
            </template>
          </el-table-column>
          <el-table-column label="附件" align="center">
            <template slot-scope="scope">
              <el-button size="mini" type="info" plain><i class="el-icon-link" /> 附件</el-button>
            </template>
          </el-table-column> -->
              <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                  <el-button size="mini" type="primary" plain @click="seeDetail(scope.row.typ, scope.row.relevenceId)">
                    查看详情</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div style="padding-top: 20px;" />

            <el-pagination :current-page="gongwenHistoryList.pageIndex" :page-sizes="[10, 20, 50, 100]"
              :page-size="gongwenHistoryList.pageCount" layout="total, prev, pager, next, jumper"
              :total="gongwenHistoryList.dataTotal" @size-change="onGongwenHistoryPageSizeChange"
              @current-change="onGongwenHistoryCurrentPageChange" />
          </el-tab-pane>

          <!-- 收藏公文Tab -->
          <el-tab-pane label="收藏公文">
            <el-table v-loading="gongwenShoucangList.listLoading" :data="gongwenShoucangList.list" style="width: 100%"
              element-loading-text="Loading" border stripe fit highlight-current-row>
              <el-table-column label="业务类型" align="center" width="100px">
                <template slot-scope="scope">
                  <b>
                    <el-tag> {{ getTypeStr(scope.row.typ) }}</el-tag>
                  </b>
                </template>
              </el-table-column>
              <el-table-column label="标题" align="center">
                <template slot-scope="scope">
                  {{ scope.row.title }}
                </template>
              </el-table-column>
              <el-table-column label="内容摘要" align="center">
                <template slot-scope="scope">
                  {{ scope.row.content }}
                </template>
              </el-table-column>
              <el-table-column label="收藏时间" align="center">
                <template slot-scope="scope">
                  {{ formatYearMonthDay(scope.row.createTime) }}
                </template>
              </el-table-column>
              <!-- <el-table-column label="图片" align="center">
            <template slot-scope="scope">

              <el-button size="mini" type="info" plain><i class="el-icon-picture-outline" /> 图片</el-button>
            </template>
          </el-table-column>
          <el-table-column label="附件" align="center">
            <template slot-scope="scope">
              <el-button size="mini" type="info" plain><i class="el-icon-link" /> 附件</el-button>
            </template>
          </el-table-column> -->
              <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                  <el-button size="mini" type="primary" plain @click="seeDetail(scope.row.typ, scope.row.relevenceId)">
                    查看详情</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div style="padding-top: 20px;" />

            <el-pagination :current-page="gongwenShoucangList.pageIndex" :page-sizes="[10, 20, 50, 100]"
              :page-size="gongwenShoucangList.pageCount" layout="total, prev, pager, next, jumper"
              :total="gongwenShoucangList.dataTotal" @size-change="onGongwenPageSizeChange"
              @current-change="onGongwenCurrentPageChange" />
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
    <el-dialog title width="60%" :visible.sync="detailDialog.visible" top="5vh">
      <qingjia-detail v-if="detailDialog.visible0" :id="detailDialog.id0" />
      <chuchai-detail v-if="detailDialog.visible1" :id="detailDialog.id1" />
      <jiaban-detail v-if="detailDialog.visible2" :id="detailDialog.id2" />
      <ruzhi-detail v-if="detailDialog.visible3" :id="detailDialog.id3" />
      <zhuanzheng-detail v-if="detailDialog.visible4" :id="detailDialog.id4" />
      <lizhi-detail v-if="detailDialog.visible5" :id="detailDialog.id5" />
      <dubandan-detail v-if="detailDialog.visible6" :id="detailDialog.id6" />
      <huiyishi-detail v-if="detailDialog.visible7" :id="detailDialog.id7" />
      <jiedaidan-detail v-if="detailDialog.visible8" :id="detailDialog.id8" />
      <jiayou-detail v-if="detailDialog.visible9" :id="detailDialog.id9" />
      <yongche-detail v-if="detailDialog.visible10" :id="detailDialog.id10" />
      <yongyin-detail v-if="detailDialog.visible11" :id="detailDialog.id11" />
      <caigou-detail v-if="detailDialog.visible13" :id="detailDialog.id13" />
      <wuzilingyong-detail v-if="detailDialog.visible14" :id="detailDialog.id14" />
      <hetongshenpi-detail v-if="detailDialog.visible15" :id="detailDialog.id15" />
      <zhaobiaoshenhe-detail v-if="detailDialog.visible16" :id="detailDialog.id16" />
      <chuanyuewenjian-detail v-if="detailDialog.visible17" :id="detailDialog.id17" />
      <gongwenliuzhuan-detail v-if="detailDialog.visible18" :id="detailDialog.id18" />
      <buka-detail v-if="detailDialog.visible19" :id="detailDialog.id19" />
      <huiyitongzhi-detail v-if="detailDialog.visible20" :id="detailDialog.id20" />
      <gongzuotongzhi-detail v-if="detailDialog.visible21" :id="detailDialog.id21" />
      <paiban-detail v-if="detailDialog.visible22" :id="detailDialog.id22" />
      <neibufawen-detail v-if="detailDialog.visible23" :id="detailDialog.id23" />
      <xianjianfawen-detail v-if="detailDialog.visible24" :id="detailDialog.id24" />
      <xuanchuanbaodao-detail v-if="detailDialog.visible25" :id="detailDialog.id25" />
      <gongzuocan-detail v-if="detailDialog.visible26" :id="detailDialog.id26" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="(detailDialog.visible = false)">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="审批" width="40%" :visible.sync="shenpiDialog.visible">
      <el-form>
        <el-form-item v-if="shenpiDialog.departVisible" label="承办部门">
          <el-checkbox-group v-model="shenpiDialog.selectedDeparts" placeholder="请选择" style="width: 100%;">
            <el-checkbox v-for="(yz, idx) in departmentList" :key="idx" :label="idx">{{ yz.name }}</el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="车牌" v-if="shenpiDialog.showSelectChepai">
          <el-select v-model="shenpiDialog.chepai" placeholder="请选择">
            <el-option v-for="item in chepaiList" :key="item.value" :label="item.label" :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-if="shenpiDialog.manyUserVisible" :label="shenpiDialog.manyUserLabel">
          <el-cascader v-model="shenpiDialog.manyUser" :options="userList" :props="props" clearable
            style="width: 100%;" />
        </el-form-item>
        <el-form-item v-if="shenpiDialog.oneUserVisible" :label="shenpiDialog.oneUserLabel">
          <el-cascader v-model="shenpiDialog.oneUser" :options="userList" clearable style="width: 100%;" />
        </el-form-item>
        <el-form-item v-if="shenpiDialog.msgVisible" label="审批信息">
          <el-input v-model="shenpiDialog.msg" type="textarea" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="rejectTask">拒 绝</el-button>
        <el-button type="primary" @click="clickAgreeBtn">{{ shenpiDialog.agreeBtnStr }}</el-button>
      </div>
    </el-dialog>

    <!-- 新建公文审批 -->
    <el-dialog title="新建事项审批" width="40%" :visible.sync="xinjainfawenShow">
      <el-form>
        <el-form-item label="审批信息">
          <el-input v-model="msg" type="textarea" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="rejectTask1(1)">拒 绝</el-button>
        <el-button type="primary" @click="clickAgreeBtn1(1)">{{ shenpiDialog.agreeBtnStr1 }}</el-button>
        <el-button type="danger" @click="clickAgreeBtn2(1)">{{ shenpiDialog.agreeBtnStr2 }}</el-button>
      </div>
    </el-dialog>
    <!-- 宣传报道审批 -->
    <el-dialog title="宣传报道审批" width="40%" :visible.sync="xuanchuanbaodaoShow">
      <el-form>
        <el-form-item label="审批信息">
          <el-input v-model="msg" type="textarea" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="rejectTask1(2)" v-if="isChengban == 1 ? false : true">拒 绝</el-button>
        <el-button type="primary" @click="clickAgreeBtn1(2)" v-if="isChengban == 1 ? false : true">{{
          shenpiDialog.agreeBtnStr1 }}</el-button>
        <el-button type="primary" @click="clickAgreeBtn1(3)" v-if="isChengban == 1 ? true : false">已完成</el-button>
        <el-button type="danger" @click="clickAgreeBtn2(2)" v-if="isChengban == 1 ? false : true">{{
          shenpiDialog.agreeBtnStr2 }}</el-button>
      </div>
    </el-dialog>
    <!-- 工作餐审批 -->
    <el-dialog title="工作餐申请审批" width="40%" :visible.sync="gongzuocanShow">
      <el-form>
        <el-form-item label="审批信息">
          <el-input v-model="msg" type="textarea" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="rejectTask1(4)">拒 绝</el-button>
        <el-button type="primary" @click="clickAgreeBtn1(4)">{{ shenpiDialog.agreeBtnStr1 }}</el-button>
        <el-button type="danger" @click="clickAgreeBtn2(4)">{{ shenpiDialog.agreeBtnStr2 }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import QingjiaDetail from "../../components/details/qingjiaDetail.vue";
import ChuchaiDetail from "../../components/details/chuchaiDetail.vue";
import JiabanDetail from "../../components/details/jiabanDetail.vue";
import RuzhiDetail from "../../components/details/ruzhiDetail.vue";
import ZhuanzhengDetail from "../../components/details/zhuanzhengDetail.vue";
import LizhiDetail from "../../components/details/lizhiDetail.vue";
import DubandanDetail from "../../components/details/dubandanDetail.vue";
import HuiyishiDetail from "../../components/details/huiyishiDetail.vue";
import JiedaidanDetail from "../../components/details/jiedaidanDetail.vue";
import JiayouDetail from "../../components/details/jiayouDetail.vue";
import YongcheDetail from "../../components/details/yongcheDetail.vue";
import YongyinDetail from "../../components/details/yongyinDetail.vue";
import CaigouDetail from "../../components/details/caigouDetail.vue";
import WuzilingyongDetail from "../../components/details/wuzilingyongDetail.vue";
import HetongshenpiDetail from "../../components/details/hetongshenpiDetail.vue";
import ZhaobiaoshenheDetail from "../../components/details/zhaobiaoshenheDetail.vue";
import ChuanyuewenjianDetail from "../../components/details/chuanyuewenjianDetail.vue";
import GongwenliuzhuanDetail from "../../components/details/gongwenliuzhuanDetail.vue";
import BukaDetail from "../../components/details/bukaDetail.vue";
import HuiyitongzhiDetail from "../../components/details/huiyitongzhiDetail.vue";
import GongzuotongzhiDetail from "../../components/details/gongzuotongzhiDetail.vue";
import PaibanDetail from "../../components/details/paibanDetail.vue";
import NeibufawenDetail from "../../components/details/neibufawenDetail.vue";
import XianjianfawenDetail from "../../components/details/xianjianfawenDetail.vue";
import xuanchuanbaodaoDetail from "../../components/details/xuanchuanbaodaoDetail.vue";
import gongzuocanDetail from "../../components/details/gongzuocanDetail.vue";

import { websock } from "@/websock";
import {
  getXinjian,
  getUserList,
  shenpiXinjian,
  getxuanchuan,
  shenpixuanchuan,
  getgongzuocan,
  shenpigongzuocan
} from "@/api2/xinjianfawen";
import moment from "moment";

export default {
  name: "Dashboard",
  components: {
    QingjiaDetail,
    ChuchaiDetail,
    JiabanDetail,
    RuzhiDetail,
    ZhuanzhengDetail,
    LizhiDetail,
    DubandanDetail,
    HuiyishiDetail,
    JiedaidanDetail,
    JiayouDetail,
    YongcheDetail,
    YongyinDetail,
    CaigouDetail,
    WuzilingyongDetail,
    HetongshenpiDetail,
    ZhaobiaoshenheDetail,
    ChuanyuewenjianDetail,
    GongwenliuzhuanDetail,
    BukaDetail,
    HuiyitongzhiDetail,
    GongzuotongzhiDetail,
    XianjianfawenDetail,
    xuanchuanbaodaoDetail,
    PaibanDetail,
    NeibufawenDetail,
    gongzuocanDetail
  },
  data() {
    return {
      isChengban: "",
      idd: "",
      msg: "",
      taskIdd: "",
      approvalProcessDataBeanMaps: [],
      props: { multiple: true },
      userInfo: {},
      userList: [],
      departmentList: [],
      chepaiList: [],
      xinjainfawenShow: false,
      xuanchuanbaodaoShow: false,
      gongzuocanShow: false,
      taskList: {
        list: null,
        listLoading: false,
        pageIndex: 1,
        pageCount: 10,
        dataTotal: 0,
        unRead: 0
      },
      noticeList: {
        list: null,
        listLoading: false,
        pageIndex: 1,
        pageCount: 10,
        dataTotal: 0,
        unRead: 0
      },
      gongwenShoucangList: {
        list: null,
        listLoading: false,
        pageIndex: 1,
        pageCount: 10,
        dataTotal: 0
      },
      gongwenHistoryList: {
        list: null,
        listLoading: false,
        pageIndex: 1,
        pageCount: 10,
        keyword: '',
        dataTotal: 0
      },
      detailDialog: {
        visible: false,
        currentIndex: -1,
        visible0: false,
        id0: 0,
        visible1: false,
        id1: 0,
        visible2: false,
        id2: 0,
        visible3: false,
        id3: 0,
        visible4: false,
        id4: 0,
        visible5: false,
        id5: 0,
        visible6: false,
        id7: 0,
        visible8: false,
        id8: 0,
        visible9: false,
        id9: 0,
        visible10: false,
        id10: 0,
        visible11: false,
        id11: 0,
        visible12: false,
        id12: 0,
        visible13: false,
        id13: 0,
        visible14: false,
        id14: 0,
        visible15: false,
        id15: 0,
        visible16: false,
        id16: 0,
        visible17: false,
        id17: 0,
        visible18: false,
        id18: 0,
        visible19: false,
        id20: 0,
        visible21: false,
        id21: 0,
        visible22: false,
        id22: 0,
        visible23: false,
        id23: 0,
        visible24: false,
        id24: 0,
        visible25: false,
        id25: 0,
        visible26: false,
        id26: 0
      },
      taskInfo1: [],
      shenpiDialog: {
        visible: false,
        msg: "",
        manyUserVisible: false,
        manyUserLabel: "选择人员",
        manyUser: [],
        oneUserVisible: false,
        oneUserLabel: "选择人员",
        oneUser: [],
        departVisible: false,
        selectedDeparts: [],
        showSelectChepai: false,
        chepai: "",
        msgVisible: false,
        agreeBtnStr: "同 意",
        idx: 0
      }
    };
  },
  beforeMount() {
    eventBus.$on('refreshShoucang', this.getGongwenShoucangList)
  },
  beforeDestroy() {
    eventBus.$off('refreshShoucang', this.getGongwenShoucangList)
  },
  async mounted() {
    this.departmentList = await websock.getDepartList();
    this.departmentList = this.departmentList.slice(1);
    this.taskInfo1 = await getUserList();
    let chepaiList = await websock.chepaiList();
    for (let i = 0; i != chepaiList.length; i++) {
      this.chepaiList.push({
        value: chepaiList[i].name,
        label: chepaiList[i].name
      });
    }

    this.getTaskList()
    this.getNotificationList()
    this.getGongwenShoucangList()
    this.getGongwenHistoryList()

    this.userInfo = await websock.getUserInfo();

    const res = await websock.getContactList();
    const userList = [];
    for (let i = 0; i !== res.length; i++) {
      userList.push({
        value: i + "",
        label: res[i].name,
        children: []
      });
      for (let j = 0; j !== res[i].userList.length; j++) {
        userList[i].children.push({
          value: JSON.stringify({
            uid: res[i].userList[j].uid,
            name: res[i].userList[j].name,
            positionName: res[i].userList[j].positionName
          }),
          label: res[i].userList[j].name
        });
      }
    }
    this.userList = userList;
  },
  methods: {
    resetIds() {
      this.detailDialog.id0 = 0;
      this.detailDialog.id1 = 0;
      this.detailDialog.id2 = 0;
      this.detailDialog.id3 = 0;
      this.detailDialog.id4 = 0;
      this.detailDialog.id5 = 0;
      this.detailDialog.id6 = 0;
      this.detailDialog.id7 = 0;
      this.detailDialog.id8 = 0;
      this.detailDialog.id9 = 0;
      this.detailDialog.id10 = 0;
      this.detailDialog.id11 = 0;
      this.detailDialog.id12 = 0;
      this.detailDialog.id13 = 0;
      this.detailDialog.id14 = 0;
      this.detailDialog.id15 = 0;
      this.detailDialog.id16 = 0;
      this.detailDialog.id17 = 0;
      this.detailDialog.id18 = 0;
      this.detailDialog.id19 = 0;
      this.detailDialog.id20 = 0;
      this.detailDialog.id21 = 0;
      this.detailDialog.id22 = 0;
      this.detailDialog.id23 = 0;
      this.detailDialog.id24 = 0;
      this.detailDialog.id25 = 0;
      this.detailDialog.id26 = 0;
    },
    getTaskList() {
      this.taskList.listLoading = true;
      websock
        .getTaskListWeb({
          pageIndex: this.taskList.pageIndex,
          pageCount: this.taskList.pageCount
        })
        .then(data => {
          this.taskList.listLoading = false;
          this.taskList.list = data.list;
          this.taskList.dataTotal = data.count;
          this.taskList.unRead = data.unRead;
        });
    },
    getNotificationList() {
      websock
        .getNotificationListWeb({
          pageIndex: this.noticeList.pageIndex,
          pageCount: this.noticeList.pageCount
        })
        .then(data => {
          console.log(data);
          this.noticeList.listLoading = false;
          this.noticeList.list = data.list;
          this.noticeList.dataTotal = data.count;
          this.noticeList.unRead = data.unRead;
        });
    },
    getGongwenShoucangList() {
      console.log('get gongwen shoucang list')
      websock.gongwenShoucangListWeb({
        pageIndex: this.gongwenShoucangList.pageIndex,
        pageCount: this.gongwenShoucangList.pageCount
      }).then(data => {
        this.gongwenShoucangList.listLoading = false
        this.gongwenShoucangList.list = data.list
        this.gongwenShoucangList.dataTotal = data.count
      })
    },
    getGongwenHistoryList() {
      console.log('get gongwen history list')
      websock.gongwenHistoryListWeb({
        keyword: this.gongwenHistoryList.keyword,
        pageIndex: this.gongwenHistoryList.pageIndex,
        pageCount: this.gongwenHistoryList.pageCount
      }).then(data => {
        this.gongwenHistoryList.listLoading = false
        this.gongwenHistoryList.list = data.list
        this.gongwenHistoryList.dataTotal = data.count
      })
    },
    onTaskPageSizeChange(val) {
      this.taskList.pageCount = val;
      this.getTaskList();
    },
    onTaskCurrentPageChange(val) {
      this.taskList.pageIndex = val;
      this.getTaskList();
    },
    onNoticePageSizeChange(val) {
      this.noticeList.pageCount = val;
      this.getNotificationList();
    },
    onNoticeCurrentPageChange(val) {
      this.noticeList.pageIndex = val;
      this.getNotificationList();
    },
    onGongwenPageSizeChange(val) {
      this.gongwenShoucangList.pageCount = val
      this.getGongwenShoucangList()
    },
    onGongwenCurrentPageChange(val) {
      this.gongwenShoucangList.pageIndex = val
      this.getGongwenShoucangList()
    },
    onGongwenHistoryPageSizeChange(val) {
      this.gongwenShoucangList.pageCount = val
      this.getGongwenHistoryList()
    },
    onGongwenHistoryCurrentPageChange(val) {
      this.gongwenShoucangList.pageIndex = val
      this.getGongwenHistoryList()
    },
    getTaskStaStr(sta) {
      if (sta === 0) {
        return "待处理";
      } else if (sta === 1) {
        return "同意";
      } else if (sta === 2) {
        return "拒绝";
      } else if (sta === 3) {
        return "已撤回";
      }
    },
    getTypeStr(typ) {
      if (typ == 0) {
        return "请假";
      }
      if (typ == 1) {
        return "出差";
      }
      if (typ == 2) {
        return "加班";
      }
      if (typ == 3) {
        return "入职";
      }
      if (typ == 4) {
        return "转正";
      }
      if (typ == 5) {
        return "离职";
      }
      if (typ == 6) {
        return "督办单";
      }
      if (typ == 7) {
        return "会议室";
      }
      if (typ == 8) {
        return "接待单";
      }
      if (typ == 9) {
        return "车辆加油";
      }
      if (typ == 10) {
        return "用车申请";
      }
      if (typ == 11) {
        return "用印申请";
      }
      if (typ == 13) {
        return "采购单";
      }
      if (typ == 14) {
        return "物资领用";
      }
      if (typ == 15) {
        return "合同审核";
      }
      if (typ == 16) {
        return "招标文件";
      }
      if (typ == 17) {
        return "传阅文件";
      }
      if (typ == 18) {
        return "公文流转";
      }
      if (typ == 19) {
        return "补卡审核";
      }
      if (typ == 20) {
        return "会议通知";
      }
      if (typ == 21) {
        return "工作通知";
      }
      if (typ == 22) {
        return "排班详情";
      }
      if (typ == 23) {
        return "内部发文";
      }
      if (typ == 24) {
        return "新建事项";
      }
      if (typ == 25) {
        return "宣传报道";
      }
      if (typ == 26) {
        return "工作餐";
      }
      return "其它";
    },
    formatYearMonthDay(src) {
      return moment(src).format("YYYY-MM-DD");
    },
    async seeDetailNotice(idx, typ, id, data) {
      if (this.noticeList.list[idx].sta === 0) {
        await websock.readNotification({
          id: this.noticeList.list[idx].id
        });
        this.getNotificationList();
      }
      console.log(idx, typ, id);
      this.seeDetail(typ, id);
    },
    seeDetail(typ, id) {
      console.log(typ, id);
      for (let i = 0; i <= 26; i++) {
        this.detailDialog["visible" + i] = false;
      }

      this.detailDialog.visible = true;
      this.detailDialog["visible" + typ] = true;
      this.detailDialog["id" + typ] = id;
      // this.taskIds = idsd;
    },
    async showShenpiDialog(idx, row) {
      console.log(idx, row);
      this.isChengban = row.isChengban;
      this.shenpiDialog.msg = "";
      this.shenpiDialog.idx = idx;
      this.shenpiDialog.manyUserVisible = false;
      this.shenpiDialog.oneUserVisible = false;
      this.shenpiDialog.manyUserLabel = "选择人员";
      this.shenpiDialog.oneUserLabel = "选择人员";
      this.shenpiDialog.manyUser = [];
      this.shenpiDialog.oneUser = [];
      this.shenpiDialog.msgVisible = true;
      this.shenpiDialog.agreeBtnStr = "同 意";
      let taskInfo = this.taskList.list[idx];
      console.log(taskInfo);
      if (taskInfo.typ == 24) {
        this.idd = row.relevenceId;
        this.taskIdd = row.id;
        const res = await getXinjian(row.relevenceId, row.id);
        console.log(res.data.newDispatch.approvalProcessDataBeanMap);
        let approvalProcessDataBeanMaps = Array.from(
          Object.values(res.data.newDispatch.approvalProcessDataBeanMap),
          x => x
        );
        this.approvalProcessDataBeanMaps = approvalProcessDataBeanMaps;
        console.log(JSON.parse(sessionStorage.getItem("loginUserinfo")).uid);
        this.xinjainfawenShow = true;
        this.shenpiDialog.agreeBtnStr1 = "同 意";
        this.shenpiDialog.agreeBtnStr2 = "撤 销";
      } else if (taskInfo.typ == 25 && row.isChengban == 0) {
        this.idd = row.relevenceId;
        this.taskIdd = row.id;
        const res = await getxuanchuan(row.relevenceId, row.id);
        console.log(res.data.propagandaReport.approvalProcessDataBeanMap);
        let approvalProcessDataBeanMaps = Array.from(
          Object.values(res.data.propagandaReport.approvalProcessDataBeanMap),
          x => x
        );
        this.approvalProcessDataBeanMaps = approvalProcessDataBeanMaps;
        console.log(JSON.parse(sessionStorage.getItem("loginUserinfo")).uid);
        this.xuanchuanbaodaoShow = true;
        this.shenpiDialog.agreeBtnStr1 = "同 意";
        this.shenpiDialog.agreeBtnStr2 = "撤 销";
      } else if (taskInfo.typ == 25 && row.isChengban == 1) {
        this.idd = row.relevenceId;
        this.taskIdd = row.id;
        const res = await getxuanchuan(row.relevenceId, row.id);
        console.log(res.data);
        let approvalProcessDataBeanMaps = Array.from(
          Object.values(res.data.propagandaReport.undertakeProcessDataMap),
          x => x
        );
        this.approvalProcessDataBeanMaps = approvalProcessDataBeanMaps;

        console.log(JSON.parse(sessionStorage.getItem("loginUserinfo")).uid);
        this.xuanchuanbaodaoShow = true;
        // this.shenpiDialog.agreeBtnStr1 = "已完成";
        // this.shenpiDialog.agreeBtnStr2 = "撤 销";
      } else if (taskInfo.typ == 26) {
        this.idd = row.relevenceId;
        this.taskIdd = row.id;
        const res = await getgongzuocan(row.relevenceId, row.id);
        console.log(res);
        let approvalProcessDataBeanMaps = Array.from(
          Object.values(res.data.workingLunch.approvalProcessDataBeanMap),
          x => x
        );
        this.approvalProcessDataBeanMaps = approvalProcessDataBeanMaps;
        console.log(JSON.parse(sessionStorage.getItem("loginUserinfo")).uid);
        this.gongzuocanShow = true;
        this.shenpiDialog.agreeBtnStr1 = "同 意";
        this.shenpiDialog.agreeBtnStr2 = "撤 销";
      } else {
        this.shenpiDialog.visible = true;
      }

      console.log("task info", taskInfo);
      // 会议室申请 承办阶段 第一个承办人 选择单人 选择具体承办
      if (taskInfo.typ == 7 && taskInfo.isChengban && taskInfo.pos == 0) {
        console.log("huiyishishenqing  chegnban");
        this.shenpiDialog.oneUserVisible = true;
        this.shenpiDialog.oneUserLabel = "选择经办人";
        this.shenpiDialog.agreeBtnStr = "确定";
        this.shenpiDialog.msgVisible = false;
      }
      // 用车申请 车队长选择车牌号
      if (taskInfo.typ == 10 && this.userInfo.uid == 12) {
        this.shenpiDialog.showSelectChepai = true;
      }
      // 传阅文件 承办阶段 周莉 选择多人 分发范围
      if (taskInfo.typ == 17) {
        if (taskInfo.isChengban) {
          this.shenpiDialog.agreeBtnStr = "确定";
          if (this.userInfo.uid == 10) {
            this.shenpiDialog.manyUserVisible = true;
            this.shenpiDialog.manyUserLabel = "选择分发范围";
            this.shenpiDialog.msgVisible = false;
          }
        }
      }
      // 公文流转
      if (taskInfo.typ == 18) {
        if (!taskInfo.isChengban && taskInfo.pos == 0) {
          this.selectBtnStr = "拟办意见";
        }

        // 审核阶段 第二个审核人 显示选择分管领导
        if (!taskInfo.isChengban && taskInfo.pos == 2) {
          this.shenpiDialog.manyUserVisible = true;
          this.shenpiDialog.manyUserLabel = "选择分管领导";
          this.selectBtnStr = "选择分管领导";
        }

        // 承办阶段 分管领导选择责任部门
        if (taskInfo.isChengban) {
          let applyInfo = await websock.gongwenLiuzhuanDetail({
            id: taskInfo.relevenceId
          });
          let chengbanren = applyInfo.chengbanren;
          if (
            chengbanren["chengbanren" + taskInfo.pos] &&
            chengbanren["chengbanren" + taskInfo.pos].fenguan
          ) {
            this.shenpiDialog.departVisible = true;
          } else {
            // 分管领导选择责任部门 其他选择经办人
            this.shenpiDialog.manyUserVisible = true;
            this.shenpiDialog.manyUserLabel = "选择经办人";
            this.selectBtnStr = "选择经办人";
          }
        }

        // if (taskInfo.isChengban && taskInfo.pos == 0) {
        //   this.shenpiDialog.oneUserVisible = true
        //   this.shenpiDialog.oneUserLabel = '人员选择'
        // }
        // // 承办阶段 第二个承办人 选择经办人
        // if (taskInfo.isChengban && taskInfo.pos == 1) {
        //   this.shenpiDialog.manyUserVisible = true
        //   this.shenpiDialog.manyUserLabel = '选择经办人'
        // }
      }
    },
    clickAgreeBtn() {
      let taskInfo = this.taskList.list[this.shenpiDialog.idx];
      if (taskInfo.isChengban) {
        this.confirmTask();
      } else {
        this.agreeTask();
      }
    },
    // 1新建发文2宣传报道审批同意
    async clickAgreeBtn1(rows) {
      console.log(rows);
      if (rows == 1) {
        const timestamp = new Date().getTime();
        // let taskInfo = this.taskList.list[this.shenpiDialog.idx];
        this.approvalProcessDataBeanMaps.forEach(data => {
          if (
            data.uid == JSON.parse(sessionStorage.getItem("loginUserinfo")).uid
          ) {
            data.msg = this.msg;
            data.sta = 1;
            data.ts = timestamp;
          }
        });
        this.approvalProcessDataBeanMaps.forEach(names => {
          this.taskInfo1.data.userList.forEach(item => {
            if (item.uid == names.uid) {
              names.signimg = item.signimg;
            }
          });
        });
        let OldObject = this.approvalProcessDataBeanMaps.reduce((o, n, i) => {
          o["auditor" + i] = {
            ts: n.ts,
            msg: n.msg,
            sta: n.sta,
            signimg: n.signimg,
            uid: n.uid,
            stepName: n.stepName,
            name: n.name
          };
          return o;
        }, {});
        const params = {
          id: this.idd,
          taskId: this.taskIdd,
          approvalProcessDataBeanMap: OldObject
        };
        try {
          const res = await shenpiXinjian(params);
          if (res.code == 0) {
            this.$message.success("审批成功");
            this.getTaskList();
          }
        } catch (err) {
          console.error(err);
        }
        this.xinjainfawenShow = false;
      } else if (rows == 2) {
        const timestamp = new Date().getTime();
        this.approvalProcessDataBeanMaps.forEach(data => {
          if (
            data.uid == JSON.parse(sessionStorage.getItem("loginUserinfo")).uid
          ) {
            data.msg = this.msg;
            data.sta = 1;
            data.ts = timestamp;
          }
        });
        this.approvalProcessDataBeanMaps.forEach(names => {
          this.taskInfo1.data.userList.forEach(item => {
            if (item.uid == names.uid) {
              names.signimg = item.signimg;
            }
          });
        });
        let OldObject = this.approvalProcessDataBeanMaps.reduce((o, n, i) => {
          o["auditor" + i] = {
            ts: n.ts,
            msg: n.msg,
            sta: n.sta,
            signimg: n.signimg,
            uid: n.uid,
            stepName: n.stepName,
            name: n.name
          };
          return o;
        }, {});
        const params = {
          id: this.idd,
          taskId: this.taskIdd,
          approvalProcessDataBeanMap: OldObject
        };
        try {
          const res = await shenpixuanchuan(params);
          if (res.code == 0) {
            this.$message.success("审批成功");
            this.getTaskList();
          }
        } catch (err) {
          console.error(err);
        }
        this.xuanchuanbaodaoShow = false;
      } else if (rows == 4) {
        const timestamp = new Date().getTime();
        this.approvalProcessDataBeanMaps.forEach(data => {
          if (
            data.uid == JSON.parse(sessionStorage.getItem("loginUserinfo")).uid
          ) {
            data.msg = this.msg;
            data.sta = 1;
            data.ts = timestamp;
          }
        });
        this.approvalProcessDataBeanMaps.forEach(names => {
          this.taskInfo1.data.userList.forEach(item => {
            if (item.uid == names.uid) {
              names.signimg = item.signimg;
            }
          });
        });
        let OldObject = this.approvalProcessDataBeanMaps.reduce((o, n, i) => {
          o["auditor" + i] = {
            ts: n.ts,
            msg: n.msg,
            sta: n.sta,
            signimg: n.signimg,
            uid: n.uid,
            stepName: n.stepName,
            name: n.name
          };
          return o;
        }, {});
        const params = {
          id: this.idd,
          taskId: this.taskIdd,
          approvalProcessDataBeanMap: OldObject
        };
        try {
          const res = await shenpigongzuocan(params);
          if (res.code == 0) {
            this.$message.success("审批成功");
            this.getTaskList();
          }
        } catch (err) {
          console.error(err);
        }
        this.gongzuocanShow = false;
      } else {
        const timestamp = new Date().getTime();
        this.approvalProcessDataBeanMaps.forEach(data => {
          if (
            data.uid == JSON.parse(sessionStorage.getItem("loginUserinfo")).uid
          ) {
            data.msg = this.msg;
            data.sta = 1;
            data.ts = timestamp;
          }
        });
        this.approvalProcessDataBeanMaps.forEach(names => {
          this.taskInfo1.data.userList.forEach(item => {
            if (item.uid == names.uid) {
              names.signimg = item.signimg;
            }
          });
        });
        let OldObject = this.approvalProcessDataBeanMaps.reduce((o, n, i) => {
          o["chengban" + i] = {
            ts: n.ts,
            msg: n.msg,
            sta: n.sta,
            signimg: n.signimg,
            uid: n.uid,
            stepName: n.stepName,
            name: n.name
          };
          return o;
        }, {});
        const params = {
          id: this.idd,
          taskId: this.taskIdd,
          undertakeProcessDataBeanMap: OldObject
        };
        console.log(params);
        try {
          const res = await shenpixuanchuan(params);
          if (res.code == 0) {
            this.$message.success("审批成功");
            this.getTaskList();
          }
        } catch (err) {
          console.error(err);
        }
        this.xuanchuanbaodaoShow = false;
      }
    },
    //1新建发文2宣传报道审批撤销
    async clickAgreeBtn2(rows) {
      if (rows == 1) {
        const timestamp = new Date().getTime();
        this.approvalProcessDataBeanMaps.forEach(data => {
          if (
            data.uid == JSON.parse(sessionStorage.getItem("loginUserinfo")).uid
          ) {
            data.msg = this.msg;
            data.sta = 3;
            data.ts = timestamp;
          }
        });
        this.approvalProcessDataBeanMaps.forEach(names => {
          this.taskInfo1.data.userList.forEach(item => {
            if (item.uid == names.uid) {
              names.signimg = item.signimg;
            }
          });
        });
        let OldObject = this.approvalProcessDataBeanMaps.reduce((o, n, i) => {
          o["auditor" + i] = {
            ts: n.ts,
            msg: n.msg,
            sta: n.sta,
            signimg: n.signimg,
            uid: n.uid,
            stepName: n.stepName,
            name: n.name
          };
          return o;
        }, {});
        const params = {
          id: this.idd,
          taskId: this.taskIdd,
          approvalProcessDataBeanMap: OldObject
        };
        try {
          const res = await shenpiXinjian(params);
          if (res.code == 0) {
            this.getTaskList();
            this.$message.success("审批成功");
          }
        } catch (err) {
          console.error(err);
        }
        this.xinjainfawenShow = false;
      } else if (rows == 4) {
        const timestamp = new Date().getTime();
        this.approvalProcessDataBeanMaps.forEach(data => {
          if (
            data.uid == JSON.parse(sessionStorage.getItem("loginUserinfo")).uid
          ) {
            data.msg = this.msg;
            data.sta = 3;
            data.ts = timestamp;
          }
        });
        this.approvalProcessDataBeanMaps.forEach(names => {
          this.taskInfo1.data.userList.forEach(item => {
            if (item.uid == names.uid) {
              names.signimg = item.signimg;
            }
          });
        });
        let OldObject = this.approvalProcessDataBeanMaps.reduce((o, n, i) => {
          o["auditor" + i] = {
            ts: n.ts,
            msg: n.msg,
            sta: n.sta,
            signimg: n.signimg,
            uid: n.uid,
            stepName: n.stepName,
            name: n.name
          };
          return o;
        }, {});
        const params = {
          id: this.idd,
          taskId: this.taskIdd,
          approvalProcessDataBeanMap: OldObject
        };
        try {
          const res = await shenpigongzuocan(params);
          if (res.code == 0) {
            this.getTaskList();
            this.$message.success("审批成功");
          }
        } catch (err) {
          console.error(err);
        }
        this.gongzuocanShow = false;
      } else {
        const timestamp = new Date().getTime();
        this.approvalProcessDataBeanMaps.forEach(data => {
          if (
            data.uid == JSON.parse(sessionStorage.getItem("loginUserinfo")).uid
          ) {
            data.msg = this.msg;
            data.sta = 3;
            data.ts = timestamp;
          }
        });
        this.approvalProcessDataBeanMaps.forEach(names => {
          this.taskInfo1.data.userList.forEach(item => {
            if (item.uid == names.uid) {
              names.signimg = item.signimg;
            }
          });
        });
        let OldObject = this.approvalProcessDataBeanMaps.reduce((o, n, i) => {
          o["auditor" + i] = {
            ts: n.ts,
            msg: n.msg,
            sta: n.sta,
            signimg: n.signimg,
            uid: n.uid,
            stepName: n.stepName,
            name: n.name
          };
          return o;
        }, {});
        const params = {
          id: this.idd,
          taskId: this.taskIdd,
          approvalProcessDataBeanMap: OldObject
        };
        try {
          const res = await shenpixuanchuan(params);
          if (res.code == 0) {
            this.getTaskList();
            this.$message.success("审批成功");
          }
        } catch (err) {
          console.error(err);
        }
        this.xuanchuanbaodaoShow = false;
      }
    },
    // 1新建发文2宣传报道审批拒绝
    async rejectTask1(rows) {
      if (rows == 1) {
        const timestamp = new Date().getTime();
        this.approvalProcessDataBeanMaps.forEach(data => {
          if (
            data.uid == JSON.parse(sessionStorage.getItem("loginUserinfo")).uid
          ) {
            data.msg = this.msg;
            data.sta = 2;
            data.ts = timestamp;
          }
        });
        this.approvalProcessDataBeanMaps.forEach(names => {
          this.taskInfo1.data.userList.forEach(item => {
            if (item.uid == names.uid) {
              names.signimg = item.signimg;
            }
          });
        });
        let OldObject = this.approvalProcessDataBeanMaps.reduce((o, n, i) => {
          o["auditor" + i] = {
            ts: n.ts,
            msg: n.msg,
            sta: n.sta,
            signimg: n.signimg,
            uid: n.uid,
            stepName: n.stepName,
            name: n.name
          };
          return o;
        }, {});
        const params = {
          id: this.idd,
          taskId: this.taskIdd,
          approvalProcessDataBeanMap: OldObject
        };
        try {
          const res = await shenpiXinjian(params);
          if (res.code == 0) {
            this.$message.success("审批成功");
            this.getTaskList();
          }
        } catch (err) {
          console.error(err);
        }
        this.xinjainfawenShow = false;
      } else if (rows == 4) {
        const timestamp = new Date().getTime();
        this.approvalProcessDataBeanMaps.forEach(data => {
          if (
            data.uid == JSON.parse(sessionStorage.getItem("loginUserinfo")).uid
          ) {
            data.msg = this.msg;
            data.sta = 2;
            data.ts = timestamp;
          }
        });
        this.approvalProcessDataBeanMaps.forEach(names => {
          this.taskInfo1.data.userList.forEach(item => {
            if (item.uid == names.uid) {
              names.signimg = item.signimg;
            }
          });
        });
        let OldObject = this.approvalProcessDataBeanMaps.reduce((o, n, i) => {
          o["auditor" + i] = {
            ts: n.ts,
            msg: n.msg,
            sta: n.sta,
            signimg: n.signimg,
            uid: n.uid,
            stepName: n.stepName,
            name: n.name
          };
          return o;
        }, {});
        const params = {
          id: this.idd,
          taskId: this.taskIdd,
          approvalProcessDataBeanMap: OldObject
        };
        try {
          const res = await shenpigongzuocan(params);
          if (res.code == 0) {
            this.$message.success("审批成功");
            this.getTaskList();
          }
        } catch (err) {
          console.error(err);
        }
        this.gongzuocanShow = false;
      } else {
        const timestamp = new Date().getTime();
        this.approvalProcessDataBeanMaps.forEach(data => {
          if (
            data.uid == JSON.parse(sessionStorage.getItem("loginUserinfo")).uid
          ) {
            data.msg = this.msg;
            data.sta = 2;
            data.ts = timestamp;
          }
        });
        this.approvalProcessDataBeanMaps.forEach(names => {
          this.taskInfo1.data.userList.forEach(item => {
            if (item.uid == names.uid) {
              names.signimg = item.signimg;
            }
          });
        });
        let OldObject = this.approvalProcessDataBeanMaps.reduce((o, n, i) => {
          o["auditor" + i] = {
            ts: n.ts,
            msg: n.msg,
            sta: n.sta,
            signimg: n.signimg,
            uid: n.uid,
            stepName: n.stepName,
            name: n.name
          };
          return o;
        }, {});
        const params = {
          id: this.idd,
          taskId: this.taskIdd,
          approvalProcessDataBeanMap: OldObject
        };
        try {
          const res = await shenpixuanchuan(params);
          if (res.code == 0) {
            this.$message.success("审批成功");
            this.getTaskList();
          }
        } catch (err) {
          console.error(err);
        }
        this.xuanchuanbaodaoShow = false;
      }
    },
    agreeTask() {
      console.log("agree task", this.shenpiDialog);
      this.shenpiDialog.visible = false;
      this.resetIds();
      let users = [];
      if (this.shenpiDialog.manyUser.length > 0) {
        for (let i = 0; i != this.shenpiDialog.manyUser.length; i++) {
          users.push(JSON.parse(this.shenpiDialog.manyUser[i][1]));
        }
      }
      if (this.shenpiDialog.oneUser.length > 0) {
        users.push(JSON.parse(this.shenpiDialog.oneUser[1]));
      }
      let taskInfo = this.taskList.list[this.shenpiDialog.idx];
      // 公文流转
      if (taskInfo.typ == 18 && taskInfo.pos == 2 && users.length == 0) {
        return this.$message.error("请选择分管领导");
      }
      websock
        .agreeTask({
          id: this.taskList.list[this.shenpiDialog.idx].id,
          msg: this.shenpiDialog.msg || "",
          chepai: this.shenpiDialog.showSelectChepai
            ? this.shenpiDialog.chepai
            : "",
          users
        })
        .then(() => {
          this.getTaskList();
        });
    },
    confirmTask() {
      this.shenpiDialog.visible = false;
      this.resetIds();
      let users = [];
      if (this.shenpiDialog.manyUser.length > 0) {
        for (let i = 0; i != this.shenpiDialog.manyUser.length; i++) {
          users.push(JSON.parse(this.shenpiDialog.manyUser[i][1]));
        }
      }
      if (this.shenpiDialog.oneUser.length > 0) {
        users.push(JSON.parse(this.shenpiDialog.oneUser[1]));
      }

      let departs = [];
      if (this.shenpiDialog.selectedDeparts.length > 0) {
        for (let i = 0; i != this.shenpiDialog.selectedDeparts.length; i++) {
          departs.push({
            departId: this.departmentList[this.shenpiDialog.selectedDeparts[i]]
              .id,
            departName: this.departmentList[
              this.shenpiDialog.selectedDeparts[i]
            ].name,
            departLingdao: this.departmentList[
              this.shenpiDialog.selectedDeparts[i]
            ].zhijie_lingdao,
            departLingdaoName: this.departmentList[
              this.shenpiDialog.selectedDeparts[i]
            ].zhijie_lingdao_name
          });
        }
      }

      websock
        .confirmTask({
          id: this.taskList.list[this.shenpiDialog.idx].id,
          msg: this.shenpiDialog.msg || "",
          users,
          departs
        })
        .then(() => {
          this.getTaskList();
        });
    },
    formatContent(content) {
      if (!content) return ''
      return content.replace(/<br>/g, '\n')
    },
    rejectTask() {
      this.shenpiDialog.visible = false;
      this.resetIds();
      websock
        .rejectTask({
          id: this.taskList.list[this.shenpiDialog.idx].id,
          msg: this.shenpiDialog.msg || ""
        })
        .then(() => {
          this.getTaskList();
        });
    },
    revertGongwen(id) {
      websock.revertGongwenLiuzhuan({ id }).then(() => {
        this.getTaskList();
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.dashboard-container {
  padding: 10px;
}

.dashboard {
  &-container {
    // padding-top: 10px;
    background-color: white;
    position: relative;
  }

  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}

.badge {
  margin: 10px 0px 0px 5px;
  border-radius: 1px;
}
</style>
